//
//  SaveHeartsViewController.m
//  SaveHearts
//
//  Created by Daehee Han on 6/25/12.
//  Copyright (c) 2012 __ac.kr.kaist.booknara__. All rights reserved.
//

#import "SaveHeartsViewController.h"
#import "ForgotViewController.h"
#import "RegisterViewController.h"
#import "LoginViewController.h"

@implementation SaveHeartsViewController

@synthesize registerButton;
@synthesize loginButton;
@synthesize forgetPwButton;

@synthesize forgotViewController;
@synthesize registerViewController;
@synthesize loginViewController;


- (id)init {
    NSLog(@"init()");
    if (self = [super init]) {

    }
    return self;
}

- (void)viewDidLoad
{
    [self drawUnderlinedLabel];
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.navigationController.navigationBar.hidden = NO;
    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftButtonPressed:)];
    self.navigationItem.leftBarButtonItem = button;

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    forgotViewController = nil;
    registerViewController = nil;
    loginViewController = nil;

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)doregisterButton:(id) sender
{
    registerViewController = [[RegisterViewController alloc] initWithNibName:@"RegisterViewController" bundle:nil];
    
    [self.navigationController pushViewController:registerViewController animated:YES];
    //[self.view addSubview:registerViewController.view];
    
}

- (IBAction)dologinButton:(id) sender
{
    loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    
    [self.navigationController pushViewController:loginViewController animated:YES];
    //[self.view addSubview:loginViewController.view];
    
}

- (IBAction)doforgetPwButton:(id) sender
{
    
    forgotViewController = [[ForgotViewController alloc] initWithNibName:@"ForgotViewController" bundle:nil];

    [self presentModalViewController:forgotViewController animated:true];
    //[self.navigationController pushViewController:forgotViewController animated:YES];
    //[self.view addSubview:forgotViewController.view];
    
}

-(void) drawUnderlinedLabel {
    NSString *string = [forgetPwButton titleForState:UIControlStateNormal];
    CGSize stringSize = [string sizeWithFont:forgetPwButton.titleLabel.font];
    CGRect buttonFrame = forgetPwButton.frame;
    CGRect labelFrame = CGRectMake(buttonFrame.origin.x + buttonFrame.size.width - stringSize.width, 
                                   buttonFrame.origin.y + stringSize.height + 1 , 
                                   stringSize.width, 2);
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:labelFrame];
    lineLabel.backgroundColor = [UIColor blackColor];
    //[forgetButton addSubview:lineLabel];
    [self.view addSubview:lineLabel];
}

@end
